package com.classroom.smart.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import org.springframework.web.servlet.config.annotation.*;

//开启SpringMVC功能
@EnableWebMvc
//开启扫描包
@ComponentScan(basePackages = {"com.classroom.smart.controller","com.classroom.smart.service"})
public class SpringMVCConfig implements WebMvcConfigurer {

    //文件上传 多部件解析器
    @Bean
    public CommonsMultipartResolver multipartResolver(){
        CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver();
        //当前多部件解析器，不仅可以支持POST请求、也可以支持PUT请求
        multipartResolver.setSupportedMethods("POST","PUT");
        multipartResolver.setMaxUploadSize(999999999);
        return multipartResolver;
    }

    //Result风格 对静态资源放行
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    //配置默认访问页面
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("/login.html");
    }

//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/image/**").addResourceLocations("file:"+System.getProperty("user.dir")+"\\src\\main\\webapp\\imageG:\\桌面\\java\\项目\\project\\src\\main\\webapp\\image\\");
//    }

    //本地图片服务器路径

    //拦截器

    //全局异常处理器

    //转换器  String -->  Date
}
